#!D:/CODE/python
# -*- coding: utf-8 -*-
# @Time : 2020/5/25 16:05
# @Author : Alexdong
# @Site : 
# @File : gevent过程.py
# @Software: PyCharm
# Functional description:

import gevent
import random
import time
from gevent import monkey

# 将程序中用到的耗时操作的代码，换为gevent中自己实现的模块
monkey.patch_all()

def corontine_work(coroutine_name):
    for i in range(10):
        print(coroutine_name, i)
        time.sleep(random.random())

gevent.joinall([
    gevent.spawn(corontine_work, "work1"),
    gevent.spawn(corontine_work, "work2")
])
